import request from '@/utils/request'
import type { ResourceCommon } from './types/resourceType'

// 获取资源列表(可以不传)
export type ResourceCondition = Partial<{
    id: number
    name: string
    startCreateTime: string
    url: string
    categoryId: string
    endCreateTime: string
    current: number
    size: number
}>

// 分页类型
export type ResourcePageData = {
    current: number
    hitCount?: false
    optimizeCountSql?: boolean
    // orders 是资源列表数据
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    orders?: any[]
    pages?: number
    records: ResourceData[] | []
    searchCount?: boolean
    size: number
    total: number
}

// 资源列表返回类型
type ResourceData = {
    categoryId: number
    createdBy: string
    createdTime: string
    description: string
    id: number
    name: string
    operatorId: number | null
    selected: boolean
    updatedBy: string
    updatedTime: string
    url: string
}


export function getResourcesPages(body: ResourceCondition) {
  return request<ResourceCommon<ResourcePageData>>({
    url: '/boss/resource/getResourcePages',
    method: 'post',
    data: body
  })
  }